home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_MultiScrolling_VBScript.asp < prev    next >
Encoding:
Text File  |  1999-07-21  |  2.7 KB  |  129 lines

  1. <% @LANGUAGE="VBSCRIPT"     %>
  2. <% Option Explicit            %>
  3.  
  4. <!--METADATA TYPE="typelib" 
  5. uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
  6. <HTML>
  7.     <HEAD>
  8.         <TITLE>MultiScrolling Database Sample</TITLE>
  9.     </HEAD>
  10.  
  11.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  12.  
  13.  
  14.         <!-- Display Header -->
  15.  
  16.         <font size="4" face="Arial, Helvetica">
  17.         <b>MultiScrolling Database Sample</b></font><br>
  18.     
  19.         <hr size="1" color="#000000">
  20.  
  21.         Contacts within the Authors Database:<br><br>
  22.  
  23.         
  24.         <%
  25.             Dim oConn    
  26.             Dim oRs        
  27.             Dim filePath    
  28.             Dim Mv        
  29.             Dim PageNo    
  30.             Dim    j        
  31.             Dim i    
  32.             
  33.             
  34.             ' Map authors database to physical path
  35.             
  36.             filePath = Server.MapPath("authors.mdb")
  37.  
  38.  
  39.             ' Create ADO Connection Component to connect with
  40.             ' sample database  
  41.             Set oConn = Server.CreateObject("ADODB.Connection")
  42.             oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
  43.  
  44.             
  45.             ' Create ADO Recordset Component
  46.             
  47.             Set oRs = Server.CreateObject("ADODB.Recordset")
  48.  
  49.  
  50.             ' Determine what PageNumber the scrolling currently is on
  51.             
  52.             Mv = Request("Mv")
  53.  
  54.             If Request("PageNo") = "" Then
  55.                 PageNo = 1
  56.             Else
  57.                 PageNo = Request("PageNo")
  58.             End If
  59.             
  60.             
  61.             ' Setup Query Recordset (4 records per page)
  62.                     
  63.             oRs.Open "SELECT * FROM Authors", oConn, adOpenStatic
  64.             oRs.PageSize = 4
  65.  
  66.             
  67.             ' Adjust PageNumber as Appropriate
  68.             
  69.             If Mv = "Page Up" or Mv = "Page Down" Then
  70.                 Select Case Mv
  71.                     Case "Page Up"
  72.                         If PageNo > 1 Then
  73.                             PageNo = PageNo - 1
  74.                         Else
  75.                             PageNo = 1
  76.                         End If
  77.                     Case "Page Down"
  78.                         If oRs.AbsolutePage < oRs.PageCount Then
  79.                             PageNo = PageNo + 1
  80.                         Else
  81.                             PageNo = oRs.PageCount
  82.                         End If
  83.                     Case Else
  84.                         PageNo = 1
  85.                 End Select
  86.             End If
  87.  
  88.             oRs.AbsolutePage = PageNo
  89.         %>
  90.  
  91.         
  92.         <!-- Draw Table of Contacts in DB -->
  93.  
  94.         <TABLE BORDER=1>
  95.             <%  For j = 1 to oRs.PageSize %>
  96.                 <TR>
  97.                     <%  For i = 0 to oRs.Fields.Count - 1 %>
  98.                         <TD VALIGN=TOP><%= oRs(i) %></TD>
  99.                     <%  Next %>
  100.                 </TR>
  101.  
  102.                 <%
  103.                     oRs.MoveNext
  104.                     
  105.                     ' Don't try to print the EOF record.
  106.                     If oRs.EOF Then
  107.                         Exit For
  108.                     End If
  109.                 Next %>
  110.         </TABLE>
  111.  
  112.  
  113.         <!-- Scrolling Navigation Control for Sample -->
  114.  
  115.         <Form Action=MultiScrolling_VBScript.asp Method="POST">
  116.             <Input Type="Hidden" Name="PageNo" Value="<%= PageNo %>">
  117.             <!-- Only show appropriate buttons -->
  118.             <%  If PageNo <  oRs.PageCount Then %>
  119.                 <INPUT TYPE="Submit" Name="Mv" Value="Page Down">
  120.             <%  End If %>
  121.  
  122.             <%  If PageNo > 1 Then %>
  123.                 <INPUT TYPE="Submit" Name="Mv" Value="Page Up">
  124.             <%  End If %>
  125.             
  126.         </Form>
  127.     </BODY>
  128. </HTML>
  129.